package com.chinaunicom.behavior.iterator;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/8/16 15:47
 * Description:
 */
public class BookShelfIterator implements Iterator{
    private BookShelf bookShelf;
    private int index;
    
    public BookShelfIterator(BookShelf bookShelf){
        this.bookShelf = bookShelf;
        this.index = 0;
    }
    
    @Override
    public boolean hasNext() {
        if (index >= this.bookShelf.getLength()){
            return false;
        }
        return true;
    }

    @Override
    public Book next() {
        return this.bookShelf.getBookAt(index++);
    }
}
